<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/29
 * Time: 10:14
 */

namespace app\api\validate;

class IdCollection extends BaseValidate
{
    protected $message = [
        'ids'=>"ids必须是以逗号分割的多个正整数ok?",
    ];

    protected $rule = [
        'ids' => 'require|checkIds',
    ];

    //定义ids验证规则
    protected function checkIds($value){
        $values = explode(",",$value);
        if (empty($values)){
            return false;
        }

        foreach ($values as $id){
            if (!$this->isPositiveIntger($id)){
                return false;
            }
        }
        return true;
    }
}